package com.fyy.utils.string;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;

public class StringToMp3 {

    public static void readStr(String str){
        ActiveXComponent ax = null;
        try {
            ax = new ActiveXComponent("Sapi.Spvoice");
            //运行时输出语音内容
            Dispatch spvoice = ax.getObject();
            //设置音量
            ax.setProperty("Volume",new Variant(100));
            //设置朗读速度
            ax.setProperty("Rate",new Variant(-2));
            //执行朗读
            Dispatch.call(spvoice,"Speak",new Variant(str));


            spvoice.safeRelease();
            ax.safeRelease();
        } catch (Exception e){
          e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        readStr("我是大神仙");
    }


}
